package com.bgs.travelapp.page;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class MyPageHelper {

    /**
     * 封装分页，页数、条数
     * @param pageRequest
     */
    public static void startPage(PageRequest pageRequest){
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
    }

    /**
     * 将分页查询的数据，封装进PageInfo工具类
     * @param list
     * @return
     */
    public static PageResult pageInfo(List list){
        PageResult pageResult = new PageResult();
        PageInfo pageInfo = new PageInfo(list);
        pageResult.setPageNum(pageInfo.getPageNum());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setContent(pageInfo.getList());
        pageResult.setTotal(pageInfo.getTotal());
        return pageResult;
    }



}
